//
//  SupplementaryInformationVC.m
//  MRBang
//
//  Created by 铅笔 on 16/4/19.
//  Copyright © 2016年 杭州易网新科技. All rights reserved.
//

#import "SupplementaryInformationVC.h"

#import "ContactInformationVC.h"//联系人 界面

#import "SelfPurchaseVehicleVC.h"//添加 自购车辆

#import "PickViewSelect.h"

@interface SupplementaryInformationVC ()<UITableViewDataSource,UITableViewDelegate,UITextFieldDelegate,pickViewStrDelegate,pathSelfPurchaseVehicleDataDelegate>
{
    UIButton *button_man,*button_woman;//性别
    int pathSex;//传递性别
    UILabel *label_man,*label_woman;
    int record_section;//记录点击的是哪一个 关系选择
    
    UITextField *textField_money;//设置金额
    NSString *str_money;//记录姓名
    BOOL isEditMoney;//标记是否是在编辑姓名

}
@property (nonatomic,strong) NSMutableArray *mutableArray_contentOne;//修改每一行 信息后
@property (nonatomic,strong) NSMutableArray *mutableArray_contentTwo;//修改每一行 信息后

@property(nonatomic,strong)PickViewSelect *pickView;

@property (nonatomic,strong) UITableView *tableView_fillInfo;

@end

@implementation SupplementaryInformationVC

- (NSMutableArray *) mutableArray_contentOne
{
    if (_mutableArray_contentOne==nil) {
        _mutableArray_contentOne = [[NSMutableArray alloc] init];
    }
    return _mutableArray_contentOne;
}

- (NSMutableArray *) mutableArray_contentTwo
{
    if (_mutableArray_contentTwo==nil) {
        _mutableArray_contentTwo = [[NSMutableArray alloc] init];
    }
    return _mutableArray_contentTwo;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"补充资料";
    self.view.backgroundColor = COLOR_EVERYVIEWBG;
    
     _mutableArray_contentOne = [@[@"商品房",@"自购有贷款",@"添加"] mutableCopy];
    
    _mutableArray_contentTwo = [@[@"填写",@"填写",@"填写",@"股份制",@"填写",@"填写",@"填写",@"填写"] mutableCopy];
    
    isEditMoney = NO;
    
    [self initWithFillInInformationVCSubviews];
    
    //注册键盘通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
}

- (void) viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    if (self.dic_pathPersonInfo[@"isortherxyk"]) {
        pathSex = [self.dic_pathPersonInfo[@"isortherxyk"] intValue];
    }
    else
    {
       pathSex = 2;//标记 性别
    }
}

#pragma mark --- 创建视图界面
- (void) initWithFillInInformationVCSubviews
{
    self.tableView_fillInfo = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight-93*PROPORTION_WIDTH-20)];
    [self.view addSubview:self.tableView_fillInfo];
    self.tableView_fillInfo.dataSource = self;
    self.tableView_fillInfo.delegate = self;
    self.tableView_fillInfo.showsVerticalScrollIndicator = NO;
    self.tableView_fillInfo.separatorStyle =UITableViewCellSeparatorStyleNone;
    self.tableView_fillInfo.backgroundColor = COLOR_EVERYVIEWBG;
    
    //下一步 button
    UIButton *button_nextAction = [[UIButton alloc] initWithFrame:CGRectMake(48*PROPORTION_WIDTH,kScreenHeight-93*PROPORTION_WIDTH-10,kScreenWidth - 48*PROPORTION_WIDTH*2, 93*PROPORTION_WIDTH)];
    [self.view addSubview:button_nextAction];
    
    [button_nextAction setBackgroundImage:[UIImage imageNamed:@"button_next"] forState:UIControlStateNormal];
    
    [button_nextAction addTarget:self action:@selector(doNextAction) forControlEvents:UIControlEventTouchUpInside];
}

#pragma  mark ----UITableViewDataSource
- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section==0) {
        return 4;
    }
    else
    {
        return 9;
    }
}

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellFillInInformationID = @"cellFillInInformationID";
    
    UITableViewCell *cell_fillInfo = [tableView cellForRowAtIndexPath:indexPath];
    if (cell_fillInfo==nil) {
        cell_fillInfo = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellFillInInformationID];
    }
    
    UIView *view_line = [[UIView alloc] initWithFrame:CGRectMake(27*PROPORTION_WIDTH, cell_fillInfo.height-1, kScreenWidth, 1.0)];
    [cell_fillInfo.contentView addSubview:view_line];
    view_line.backgroundColor = [BaseViewController colorWithHexString:@"#EEEFF1"];
    
    cell_fillInfo.selectionStyle = UITableViewCellSelectionStyleNone;
    
    NSArray *array_title = @[ @[@"住宅类型",@"住宅性质",@"自购车辆",@"有无其他信用卡"],@[@"职业资料",@"*单位全称",@"*任职部门",@"*职位/岗位",@"*单位性质",@"*单位地址",@"*单位电话",@"*年收入",@"*现公司工龄"]];
    
    UILabel *label_leftTitle = [[UILabel alloc] initWithFrame:CGRectMake(27*PROPORTION_WIDTH, 27*PROPORTION_WIDTH, 210*PROPORTION_WIDTH, 20)];
    [cell_fillInfo addSubview:label_leftTitle];
    
    label_leftTitle.font = [UIFont systemFontOfSize:30*PROPORTION_WIDTH];
    label_leftTitle.textColor = [BaseViewController colorWithHexString:@"#666666"];
    
    //右侧 文字
    UILabel *label_rightContent = [[UILabel alloc] initWithFrame:CGRectMake(label_leftTitle.right+5, 22*PROPORTION_WIDTH, 428*PROPORTION_WIDTH, 20)];
    [cell_fillInfo addSubview:label_rightContent];
    label_rightContent.font = [UIFont systemFontOfSize:30*PROPORTION_WIDTH];
    label_rightContent.textColor = [BaseViewController colorWithHexString:@"#AAAAAA"];

    if (indexPath.section==0) {
        NSArray *array_temp = array_title[0];

        label_leftTitle.text = array_temp[indexPath.row];
        
        if (indexPath.row!=3) {
            
           label_rightContent.text = self.mutableArray_contentOne[indexPath.row];
            
            //button
            UIButton *button_rightArrow = [[UIButton alloc] initWithFrame:CGRectMake(kScreenWidth-30, 12, 20, 20)];
            [cell_fillInfo.contentView addSubview:button_rightArrow];
            [button_rightArrow setImage:[UIImage imageNamed:@"return_right"] forState:UIControlStateNormal];
            
            if (indexPath.row==0) {
                if (self.dic_pathPersonInfo[@"hometype"]) {
                    NSString *str_hometype;
                    int hometype = [self.dic_pathPersonInfo[@"hometype"] intValue];
                    if (hometype==1) {
                        str_hometype = @"商品房";
                    }
                    if (hometype==2) {
                        str_hometype = @"福利房";
                    }
                    if (hometype==3) {
                        str_hometype = @"经济适用房";
                    }
                    if (hometype==4) {
                        str_hometype = @"自建";
                    }
                    if (hometype==5) {
                        str_hometype = @"其他";
                    }
                    label_rightContent.text = [NSString stringWithFormat:@"%@",str_hometype];
                }
            }
            
            if (indexPath.row==1) {
                
                if (self.dic_pathPersonInfo[@"homexingzhi"]) {
                    
                    NSString *str_homexingzhi;
                    int homexingzhi = [self.dic_pathPersonInfo[@"homexingzhi"] intValue];
                    if (homexingzhi==1) {
                        str_homexingzhi = @"自购无贷款";
                    }
                    if (homexingzhi==2) {
                        str_homexingzhi = @"自购有贷款";
                    }
                    if (homexingzhi==3) {
                        str_homexingzhi = @"租用";
                    }
                    if (homexingzhi==4) {
                        str_homexingzhi = @"父母同住";
                    }
                    if (homexingzhi==5) {
                        str_homexingzhi = @"公司宿舍";
                    }
                    if (homexingzhi==6) {
                        str_homexingzhi = @"其他";
                    }
                    label_rightContent.text = [NSString stringWithFormat:@"%@",str_homexingzhi];
                }

                //金钱
                //UITextField
                textField_money = [[UITextField alloc] initWithFrame:CGRectMake(kScreenWidth-290*PROPORTION_WIDTH, label_rightContent.y, 220*PROPORTION_WIDTH, label_rightContent.height)];
                [cell_fillInfo addSubview:textField_money];
                textField_money.font = [UIFont systemFontOfSize:30*PROPORTION_WIDTH];
                textField_money.textColor = [BaseViewController colorWithHexString:@"#AAAAAA"];
                textField_money.delegate = self;
                
                textField_money.placeholder = @"请输入金额";

                if (self.dic_pathPersonInfo[@"homexingprice"]) {
                    textField_money.text = self.dic_pathPersonInfo[@"homexingprice"];
                }
                textField_money.backgroundColor = COLOR_EVERYVIEWBG;
                
                textField_money.hidden = YES;
                
                if ([str_money isEqualToString:@"自购无贷款"] || [str_money isEqualToString:@"租用"]) {
                    textField_money.hidden = NO;
                }
            }
            if (indexPath.row==2) {
                if (self.dic_pathPersonInfo[@"carnum"]) {
                    label_rightContent.text = [NSString stringWithFormat:@"%@",self.dic_pathPersonInfo[@"carnum"]];
                }
            }
        }
        if (indexPath.row==3) {
            //性别
            //男 有
            button_man = [[UIButton alloc] initWithFrame:CGRectMake(255*PROPORTION_WIDTH,27*PROPORTION_WIDTH, 38*PROPORTION_WIDTH, 38*PROPORTION_WIDTH)];
            [cell_fillInfo.contentView addSubview:button_man];
            button_man.tag = 33;
            [button_man addTarget:self action:@selector(choseSexManOrWoman:) forControlEvents:UIControlEventTouchUpInside];
            
            label_man = [[UILabel alloc] initWithFrame:CGRectMake(button_man.right+5, 22*PROPORTION_WIDTH, 30,20)];
            [cell_fillInfo.contentView addSubview:label_man];
            label_man.text = @"有";
            label_man.textColor = [BaseViewController colorWithHexString:@"#AAAAAA"];
            label_man.font = [UIFont systemFontOfSize:Font_SIZE_14];
            
            //女 无
            button_woman = [[UIButton alloc] initWithFrame:CGRectMake(label_man.right+10,27*PROPORTION_WIDTH, button_man.width, button_man.height)];
            [cell_fillInfo.contentView addSubview:button_woman];
            button_woman.tag = 34;
            [button_woman addTarget:self action:@selector(choseSexManOrWoman:) forControlEvents:UIControlEventTouchUpInside];
            
            label_woman = [[UILabel alloc] initWithFrame:CGRectMake(button_woman.right+5, 22*PROPORTION_WIDTH, 30,20)];
            [cell_fillInfo.contentView addSubview:label_woman];
            label_woman.text = @"无";
            label_woman.textColor = [BaseViewController colorWithHexString:@"#AAAAAA"];
            label_woman.font = [UIFont systemFontOfSize:Font_SIZE_14];
            
            if (pathSex==1) {
                [button_man setImage:[UIImage imageNamed:@"selected"] forState:UIControlStateNormal];
                [button_woman setImage:[UIImage imageNamed:@"unselected"] forState:UIControlStateNormal];
            }
            if (pathSex==0)
            {
                [button_woman setImage:[UIImage imageNamed:@"selected"] forState:UIControlStateNormal];
                [button_man setImage:[UIImage imageNamed:@"unselected"] forState:UIControlStateNormal];
            }
            if (pathSex==2)
            {
                [button_woman setImage:[UIImage imageNamed:@"unselected"] forState:UIControlStateNormal];
                [button_man setImage:[UIImage imageNamed:@"unselected"] forState:UIControlStateNormal];
            }
        }
    }
    if (indexPath.section==1) {
        NSArray *array_temp = array_title[1];
        
        label_leftTitle.text = array_temp[indexPath.row];
        
        NSRange range1 = [label_leftTitle.text rangeOfString: @"*"];
        
        NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString: label_leftTitle.text];
        [attribute addAttributes: @{NSForegroundColorAttributeName:[UIColor redColor]}range: range1];
        
        [attribute addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:30*PROPORTION_WIDTH] range:range1];
        [label_leftTitle setText: label_leftTitle.text];
        [label_leftTitle setAttributedText: attribute];
        
        if (indexPath.row==4) {
            label_rightContent.text = self.mutableArray_contentTwo[indexPath.row-1];
            
            if (self.dic_pathPersonInfo[@"companyxingzhi"]) {
                
                NSString *str_companyxingzhi;
                int companyxingzhi = [self.dic_pathPersonInfo[@"companyxingzhi"]intValue];
                
                if (companyxingzhi==1) {
                    str_companyxingzhi = @"机关事业";
                }
                if (companyxingzhi==2) {
                    str_companyxingzhi = @"国有";
                }
                if (companyxingzhi==3) {
                    str_companyxingzhi = @"民营";
                }
                if (companyxingzhi==4) {
                    str_companyxingzhi = @"合资/合作";
                }
                if (companyxingzhi==5) {
                    str_companyxingzhi = @"股份制";
                }
                if (companyxingzhi==6) {
                    str_companyxingzhi = @"个体私营";
                }
                if (companyxingzhi==7) {
                    str_companyxingzhi = @"其他";
                }
                
                label_rightContent.text = [NSString stringWithFormat:@"%@",str_companyxingzhi];
            }
        }
        
        if (indexPath.row!=0&&indexPath.row!=4) {
            
            //UITextField
            UITextField *textField_finll = [[UITextField alloc] initWithFrame:label_rightContent.frame];
            [cell_fillInfo addSubview:textField_finll];
            textField_finll.font = [UIFont systemFontOfSize:30*PROPORTION_WIDTH];
            textField_finll.textColor = [BaseViewController colorWithHexString:@"#AAAAAA"];
            
            textField_finll.tag = indexPath.row;
            textField_finll.delegate = self;
            
            textField_finll.placeholder = self.mutableArray_contentTwo[indexPath.row-1];
            if (indexPath.row==1) {
                
                if ([self.dic_pathPersonInfo[@"company"] length]!=0) {
                    
                    textField_finll.text = [NSString stringWithFormat:@"%@",self.dic_pathPersonInfo[@"company"]];
                    
                    [self.mutableArray_contentTwo replaceObjectAtIndex:indexPath.row-1 withObject:self.dic_pathPersonInfo[@"company"]];
                }
            }
            if (indexPath.row==2) {
                if ([self.dic_pathPersonInfo[@"department"] length]!=0) {
                    textField_finll.text = [NSString stringWithFormat:@"%@",self.dic_pathPersonInfo[@"department"]];
                    
                     [self.mutableArray_contentTwo replaceObjectAtIndex:indexPath.row-1 withObject:self.dic_pathPersonInfo[@"company"]];
                }
            }
            if (indexPath.row==3) {
                if ([self.dic_pathPersonInfo[@"position"] length]!=0) {
                    textField_finll.text = [NSString stringWithFormat:@"%@",self.dic_pathPersonInfo[@"position"]];
                    
                     [self.mutableArray_contentTwo replaceObjectAtIndex:indexPath.row-1 withObject:self.dic_pathPersonInfo[@"company"]];
                }
            }
            if (indexPath.row==5) {
                if ([self.dic_pathPersonInfo[@"companyaddress"] length]!=0) {
                    textField_finll.text = [NSString stringWithFormat:@"%@",self.dic_pathPersonInfo[@"companyaddress"]];
                     [self.mutableArray_contentTwo replaceObjectAtIndex:indexPath.row-1 withObject:self.dic_pathPersonInfo[@"company"]];
                }
            }
            if (indexPath.row==6) {
                if ([self.dic_pathPersonInfo[@"companttel"] length]!=0) {
                    textField_finll.text = [NSString stringWithFormat:@"%@",self.dic_pathPersonInfo[@"companttel"]];
                     [self.mutableArray_contentTwo replaceObjectAtIndex:indexPath.row-1 withObject:self.dic_pathPersonInfo[@"company"]];
                }
            }
            if (indexPath.row==7) {
                if ([self.dic_pathPersonInfo[@"nianshouru"] length]!=0) {
                    textField_finll.text = [NSString stringWithFormat:@"%@",self.dic_pathPersonInfo[@"nianshouru"]];
                     [self.mutableArray_contentTwo replaceObjectAtIndex:indexPath.row-1 withObject:self.dic_pathPersonInfo[@"company"]];
                }
            }
            if (indexPath.row==8) {
                if ([self.dic_pathPersonInfo[@"companyage"] length]!=0) {
                    textField_finll.text = [NSString stringWithFormat:@"%@",self.dic_pathPersonInfo[@"companyage"]];
                     [self.mutableArray_contentTwo replaceObjectAtIndex:indexPath.row-1 withObject:self.dic_pathPersonInfo[@"company"]];
                }
            }
        }
        
        if (indexPath.row==0) {
            label_leftTitle.textColor = [UIColor blackColor];
            view_line.frame = CGRectMake(0,cell_fillInfo.height-10.0*PROPORTION_WIDTH,kScreenWidth,10.0*PROPORTION_WIDTH);
        }
        
        if (indexPath.row==4) {
            //button
            UIButton *button_rightArrow = [[UIButton alloc] initWithFrame:CGRectMake(kScreenWidth-30, 12, 20, 20)];
            [cell_fillInfo.contentView addSubview:button_rightArrow];
            [button_rightArrow setImage:[UIImage imageNamed:@"return_right"] forState:UIControlStateNormal];
            
        }
    }
    return cell_fillInfo;
}

//选择则性别
- (void)choseSexManOrWoman:(UIButton *)sender
{
    NSLog(@"dddddd");
    //    性别，0女1男
    if (sender.tag==33)
    {
        pathSex = 1;
        [button_woman setImage:[UIImage imageNamed:@"unselected"] forState:UIControlStateNormal];
        [button_man setImage:[UIImage imageNamed:@"selected"] forState:UIControlStateNormal];
    }
    else
    {
        pathSex = 0;
        [button_man setImage:[UIImage imageNamed:@"unselected"] forState:UIControlStateNormal];
        [button_woman setImage:[UIImage imageNamed:@"selected"] forState:UIControlStateNormal];
    }
}

- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    record_section = indexPath.section;

    NSArray *array_allData;
    if (indexPath.section==0) {
        if (indexPath.row==0||indexPath.row==1) {
            array_allData = @[@[@"商品房",@"福利房",@"经济适用房",@"自建",@"其他"],@[@"自购无贷款",@"自购有贷款",@"租用",@"父母同住",@"公司宿舍",@"其他"]];
            
            _pickView =[[PickViewSelect alloc]initWithDataArr:array_allData[indexPath.row] andRowIndex:(int)indexPath.row];
                _pickView.delegate = self;
            [self.view addSubview:_pickView];

        }
        if (indexPath.row==2) {
            SelfPurchaseVehicleVC *selfPurchaseView = [[SelfPurchaseVehicleVC alloc] init];
            selfPurchaseView.vehicleDelegate = self;
            selfPurchaseView.dic_pathPersonInfo = self.dic_pathPersonInfo;
            [self.navigationController pushViewController:selfPurchaseView animated:YES];
        }
        
    }
    if (indexPath.section==1&&indexPath.row==4) {
        
        array_allData = @[@"机关事业",@"国有",@"民营",@"合资/合作",@"股份制",@"个体私营",@"其它"];
        
        _pickView =[[PickViewSelect alloc]initWithDataArr:array_allData andRowIndex:3];
        _pickView.delegate = self;
        [self.view addSubview:_pickView];
    }

    //键盘退出
    [self commentTableViewTouchInSide];
}

#pragma mark -- pathSelfPurchaseVehicleDataDelegate
- (void) pathSelfPurchaseVehicleData:(NSMutableArray *)mutableArray_vehicle
{
    
    [self.mutableArray_contentOne replaceObjectAtIndex:2 withObject:mutableArray_vehicle[2]];
    
    [self.dic_pathPersonInfo setObject:mutableArray_vehicle[0] forKey:@"carpp"];
    
    [self.dic_pathPersonInfo setObject:mutableArray_vehicle[1] forKey:@"carprice"];
    [self.dic_pathPersonInfo setObject:mutableArray_vehicle[2] forKey:@"carnum"];
    [self.dic_pathPersonInfo setObject:mutableArray_vehicle[3] forKey:@"cartime"];
    
    [self.tableView_fillInfo reloadData];
}

#pragma mark -- picker delegate
- (void) pickViewdelegateWith:(NSString *)messStr andRow:(int)rowIndex andSelectecRow:(int)selectedRow
{
    if (record_section==0) {
        if (rowIndex==0) {
            
            int hometype=0;
            
            if ([messStr isEqualToString:@"商品房"]) {
                hometype = 1;
            }
            if ([messStr isEqualToString:@"福利房"]) {
                hometype = 2;
            }
            if ([messStr isEqualToString:@"经济适用房"]) {
                hometype = 3;
            }
            if ([messStr isEqualToString:@"自建"]) {
                hometype = 4;
            }
            if ([messStr isEqualToString:@"其他"]) {
                hometype = 5;
            }
            
            [self.dic_pathPersonInfo setObject:[NSNumber numberWithInt:hometype] forKey:@"hometype"];
        }
        if (rowIndex==1) {
            int hometype=0;
            
            if ([messStr isEqualToString:@"自购无贷款"]) {
                hometype = 1;
            }
            if ([messStr isEqualToString:@"自购有贷款"]) {
                hometype = 2;
            }
            if ([messStr isEqualToString:@"租用"]) {
                hometype = 3;
            }
            if ([messStr isEqualToString:@"父母同住"]) {
                hometype = 4;
            }
            if ([messStr isEqualToString:@"公司宿舍"]) {
                hometype = 5;
            }
            if ([messStr isEqualToString:@"其他"]) {
                hometype = 6;
            }
            [self.dic_pathPersonInfo setObject:[NSNumber numberWithInt:hometype] forKey:@"homexingzhi"];
        }

      [self.mutableArray_contentOne replaceObjectAtIndex:rowIndex withObject:messStr];
        str_money = messStr;
    }
    if (record_section==1) {
        
        int companyxingzhi=0;
        
        if ([messStr isEqualToString:@"机关事业"]) {
            companyxingzhi = 1;
        }
        if ([messStr isEqualToString:@"国有"]) {
            companyxingzhi = 2;
        }
        if ([messStr isEqualToString:@"民营"]) {
            companyxingzhi = 3;
        }
        if ([messStr isEqualToString:@"合资/合作"]) {
            companyxingzhi = 4;
        }
        if ([messStr isEqualToString:@"股份制"]) {
            companyxingzhi = 5;
        }
        if ([messStr isEqualToString:@"个体私营"]) {
            companyxingzhi = 6;
        }
        if ([messStr isEqualToString:@"其他"]) {
            companyxingzhi = 7;
        }
        
        [self.dic_pathPersonInfo setObject:[NSNumber numberWithInt:companyxingzhi] forKey:@"companyxingzhi"];
        
        [self.mutableArray_contentTwo replaceObjectAtIndex:3 withObject:messStr];
    }
    
    [self.tableView_fillInfo reloadData];
}

//文字内容替换
- (void) textFieldDidEndEditing:(UITextField *)textField
{
    if (textField!=textField_money && textField.text.length!=0) {
        if (textField.tag == 1) {
            [self.dic_pathPersonInfo setObject:textField.text forKey:@"company"];
        }
        
        if (textField.tag == 2) {
            [self.dic_pathPersonInfo setObject:textField.text forKey:@"department"];
        }
        if (textField.tag == 3) {
            [self.dic_pathPersonInfo setObject:textField.text forKey:@"position"];
            
        }
        if (textField.tag == 5) {
            [self.dic_pathPersonInfo setObject:textField.text forKey:@"companyaddress"];
        }
        if (textField.tag == 6) {
            [self.dic_pathPersonInfo setObject:textField.text forKey:@"companttel"];
        }
        if (textField.tag == 7) {
            
            [self.dic_pathPersonInfo setObject:textField.text forKey:@"nianshouru"];
        }
        if (textField.tag == 8) {
            
            [self.dic_pathPersonInfo setObject:textField.text forKey:@"companyage"];
        }

        [self.mutableArray_contentTwo replaceObjectAtIndex:textField.tag-1 withObject:textField.text];
    }
    else
    {
        [self.dic_pathPersonInfo setObject:textField.text forKey:@"homexingprice"];
    }
    
    [self.tableView_fillInfo reloadData];
}

- (void) textFieldDidBeginEditing:(UITextField *)textField
{
    
    if (textField==textField_money) {
        
        isEditMoney = YES;
    }
    else
    {
        isEditMoney = NO;
    }
}



#pragma mark  --- 点击tableView 收回键盘
- (void)commentTableViewTouchInSide
{
    UITextField *textField_temp1 = (UITextField *)[self.view viewWithTag:1];
    
    [textField_temp1 resignFirstResponder];
    
    UITextField *textField_temp2 = (UITextField *)[self.view viewWithTag:2];
    
    [textField_temp2 resignFirstResponder];
    
    UITextField *textField_temp3 = (UITextField *)[self.view viewWithTag:3];
    
    [textField_temp3 resignFirstResponder];
    
    UITextField *textField_temp4 = (UITextField *)[self.view viewWithTag:4];
    
    [textField_temp4 resignFirstResponder];
    
    UITextField *textField_temp5 = (UITextField *)[self.view viewWithTag:5];
    
    [textField_temp5 resignFirstResponder];
    
    UITextField *textField_temp6 = (UITextField *)[self.view viewWithTag:6];
    
    [textField_temp6 resignFirstResponder];

    UITextField *textField_temp7 = (UITextField *)[self.view viewWithTag:7];
    
    [textField_temp7 resignFirstResponder];
    
    UITextField *textField_temp8 = (UITextField *)[self.view viewWithTag:8];
    
    [textField_temp8 resignFirstResponder];
    
    [textField_money resignFirstResponder];
}

- (void) touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self.view endEditing:YES];
}

#pragma mark --- 下一步
- (void) doNextAction
{
    
//    if ( [self.mutableArray_contentTwo containsObject:@"填写"]) {
//        [UIView showAlertMsg:@"请完善信息"];
//        return;
//    }

    ContactInformationVC *contactInfoView = [[ContactInformationVC alloc] init];
    
    contactInfoView.dic_pathPersonInfo = self.dic_pathPersonInfo;
    
    [self.navigationController pushViewController:contactInfoView animated:NO];
    
}

#pragma mark keyboardNotification

- (void)keyboardWillShow:(NSNotification*)notification{
    
    if (isEditMoney==NO)
    {
        CGRect _keyboardRect = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
        
        //如果self在键盘之下 才做偏移
        if ([self convertYToWindow:CGRectGetMaxY(self.tableView_fillInfo.frame)]>=_keyboardRect.origin.y)
        {
            //没有偏移 就说明键盘没出来，使用动画
            if (self.view.frame.origin.y== self.tableView_fillInfo.frame.origin.y) {
                
                [UIView animateWithDuration:0.3 animations:^{
                    self.view.frame = CGRectMake(0, -_keyboardRect.size.height+[self getHeighOfWindow]-CGRectGetMaxY(self.view.frame)+50, kScreenWidth, kScreenHeight);
                }];
            }
            else
            {
                self.view.frame = CGRectMake(0,0, kScreenWidth, kScreenHeight);
            }
        }
        
    }
    
}

- (void)keyboardWillHide:(NSNotification*)notification{
    
    [UIView animateWithDuration:0.3 animations:^{
        self.view.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight);
    }];
}

#pragma  mark ConvertPoint
//将坐标点y 在window和superview转化  方便和键盘的坐标比对
-(float)convertYFromWindow:(float)Y
{
    AppDelegate *appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
    CGPoint o = [appDelegate.window convertPoint:CGPointMake(0, Y) toView:self.view];
    return o.y;
    
}
-(float)convertYToWindow:(float)Y
{
    AppDelegate *appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
    CGPoint o = [self.view convertPoint:CGPointMake(0, Y) toView:appDelegate.window];
    return o.y;
    
}
-(float)getHeighOfWindow
{
    AppDelegate *appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
    return appDelegate.window.frame.size.height;
}

-(void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
   
}

@end
